package vn.sunnet.game.SinhTon.object;

import vn.sunnet.game.SinhTon.global.Assets;
import vn.sunnet.game.SinhTon.global.Setting;

import com.badlogic.gdx.graphics.g2d.TextureRegion;

// Lô cốt
public class Blockhouse extends GameObject {
	private int id;
	private String name;
	private float blood, max_Blood;
	private int coinValue;
	private boolean isLose;
	private boolean isCanBuy;// dieu kien su dung
	private int mapCanBuy;

	public Blockhouse(int id) {
		super(91 + 155 * (id - 2), 66, 129, 92);
		// 129 va 92 lan luot la chieu dai va kich thuoc cua locot
		this.id = id;
		switch (id) {
		case 1:
			name = "LC bao đất";
			blood = max_Blood = 100;
			coinValue = 0;
			isCanBuy = true;
			mapCanBuy = 1;
			break;
		case 2:
			name = "LC bao cát";
			blood = max_Blood = 125;
			coinValue = 2200;
			isCanBuy = true;
			mapCanBuy = 1;
			break;
		case 3:
			name = "LC bao sét";
			blood = max_Blood = 150;
			coinValue = 2800;
			// Dieu kien la phai o map 3
			isCanBuy = Setting.getBoolean("MAP" + 3);
			mapCanBuy = 3;
			break;
		case 4:
			name = "LC bao gạch";
			blood = max_Blood = 175;
			coinValue = 3000;
			isCanBuy = Setting.getBoolean("MAP" + 4);
			mapCanBuy = 4;
			break;
		case 5:
			name = "LC bê-tông";
			blood = max_Blood = 200;
			coinValue = 3500;
			isCanBuy = Setting.getBoolean("MAP" + 6);
			mapCanBuy = 6;
			break;
		case 6:
			name = "LC thép";
			blood = max_Blood = 225;
			coinValue = 3800;
			isCanBuy = Setting.getBoolean("MAP" + 8);
			mapCanBuy = 8;
			break;
		}
	}

	public TextureRegion getTexture() {
		return Assets.trBlockhouse.get(id - 2);
	}

	public TextureRegion getTexture_hover() {
		return Assets.trBlockhouse_hover.get(id - 2);
	}

	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public float getBlood() {
		return blood;
	}

	public void setBlood(int blood) {
		this.blood = blood;
	}

	public int getCoinValue() {
		return coinValue;
	}

	public void setCoinValue(int coinValue) {
		this.coinValue = coinValue;
	}

	// xu ly khi zombie tan cong
	public void decreaseBlood(float damageSpeed, float time) {
		// Gdx.app.log("", blood + " blood");
		this.blood -= damageSpeed * time;
		// Gdx.app.log("", damageSpeed * time + " blood 2");
		// Gdx.app.log("", blood + " blood 1");
		if (this.blood <= 0) {
			this.isLose = true;
			// am thanh tan cong cua Zombie
		}
	}

	public void restoreBlood(float time) {
		blood = max_Blood;
	}

	public boolean isLose() {
		return isLose;
	}

	public float getMaxBlood() {
		return max_Blood;
	}
	
	public boolean isCanBuy() {
		return isCanBuy;
	}

	public int getMapCanBuy() {
		return mapCanBuy;
	}

}
